/* Preview.css - Refined Styles */

/* --- Root Variables for Color Palette (Optional but Good Practice) --- */
:root {
    --preview-bg: #ffffff;             /* Light background for preview */
    --preview-text-color: #333333;     /* Dark text for readability */
    --heading-color: #111111;          /* Strong, almost black headings */
    --link-color: #0366d6;             /* GitHub-style blue links */
    --link-hover-color: #024ea2;       /* Darker blue on hover */
    --code-bg: #f5f5f5;                /* Light gray code background */
    --code-text-color: #24292e;        /* Dark gray code text */
    --blockquote-bg: #f9f9f9;          /* Very light gray blockquote background */
    --blockquote-border: #d1d5da;      /* Soft gray blockquote border */
    --hr-color: #e1e4e8;               /* Subtle gray horizontal rule */
    --main-border-color: #d1d5da;      /* Table cell border color */
    --table-header-bg: #f6f8fa;        /* Light header row background */
    --table-stripe-bg: #f2f2f2;        /* Even row stripe background */
    --copy-button-bg: #0366d6;         /* Blue copy button */
    --copy-button-hover-bg: #024ea2;   /* Darker on hover */
    --copy-button-bg-rgb-values: 3,102,214; /* For focus shadow */
}


/* General styles for the preview content area */
.preview-content {
    max-width: 950px;
    margin: 0 auto;
    padding: 10px 10px;
    background-color: transparent;
    border-radius: 6px;
    font-family: 'Roboto', sans-serif;
    color: var(--preview-text-color);
    line-height: 1.8;
    word-wrap: break-word;
    height: 100%;
    font-size: 1.05rem;
}

/* Headings within the preview content */
.preview-content h1,
.preview-content h2,
.preview-content h3,
.preview-content h4,
.preview-content h5,
.preview-content h6 {
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    color: var(--heading-color);
    margin-top: 20px;
    margin-bottom: 20px;
    line-height: 1.3;
    letter-spacing: -0.02em;
    text-transform: none;
}

.preview-content h1 {
    font-size: 2rem;
    border-bottom: 0.0625rem solid var(--hr-color);
    padding-bottom: 0.3em;
}

.preview-content h2 {
    font-size: 2.2rem;
}

.preview-content h3 {
    font-size: 1.8rem;
}

.preview-content h4 {
    font-size: 1.5rem;
}

.preview-content h5 {
    font-size: 1.25rem;
}

.preview-content h6 {
    font-size: 1.1rem;
    color: var(--preview-text-color);
    font-weight: 500;
}

/* Paragraphs within the preview content */
.preview-content p {
    margin-bottom: 20px;
    font-size: 0.875rem;
    color: var(--preview-text-color);
}

/* Links within the preview content */
.preview-content a {
    color: var(--link-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease, text-shadow 0.3s ease;
}

.preview-content a:hover {
    color: var(--link-hover-color);
    text-decoration: underline;
    text-shadow: 0 0 3px var(--link-hover-color);
}

/* Lists within the preview content */
.preview-content ul,
.preview-content ol {
    margin-left: 30px;
    margin-bottom: 20px;
}

.preview-content li {
    margin-bottom: 10px;
    line-height: 1.6;
}

/* Code blocks within the preview content */
.preview-content pre {
    background-color: var(--code-bg);
    color: var(--code-text-color);
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 25px;
    font-family: 'Fira Code', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    border: 1px solid var(--hr-color);
}

.preview-content pre code {
    display: block;
    padding: 0;
    background: none;
    color: inherit;
}

/* Style for inline code */
.preview-content code:not(pre code) {
    font-family: 'Fira Code', monospace;
    background-color: var(--code-bg);
    color: var(--code-text-color);
    padding: 3px 6px;
    border-radius: 5px;
    font-size: 0.9rem;
    border: 1px solid var(--hr-color);
}

/* Blockquotes */
.preview-content blockquote {
    border-left: 6px solid var(--blockquote-border);
    background-color: var(--blockquote-bg);
    padding: 20px 25px;
    margin: 20px 0;
    font-style: italic;
    color: var(--preview-text-color);
    border-radius: 0 8px 8px 0;
    quotes: "\201C""\201D""\2018""\2019";
}

.preview-content blockquote::before {
    color: var(--blockquote-border);
    content: open-quote;
    font-size: 4em;
    line-height: 0.1em;
    margin-right: 0.25em;
    vertical-align: -0.4em;
}


.preview-content blockquote p {
    margin-bottom: 0;
    font-size: 1.05rem;
}

/* Horizontal Rules (---, ***, etc. in Markdown) */
.preview-content hr {
    border: none;
    border-top: 1.5px solid var(--hr-color);
    margin: 35px 0;
    opacity: 0.7;
}

/* Tables */
.preview-content table {
    display: block;
    width: 100%;
    width: max-content;
    max-width: 100%;
    overflow: auto;
    font-variant: tabular-nums;
    margin-bottom: 1rem;
}

.preview-content th,
.preview-content td {
    text-align: left;
    border: 1px solid var(--main-border-color);
}

.preview-content th {
    background-color: var(--table-header-bg);
    font-weight: bold;
    color: var(--heading-color);
}
.preview-content tr:nth-child(even) td {
    background-color: var(--table-stripe-bg); 
}

/* --- Code Copy Button Styles --- */
.preview-content .code-block-container {
    position: relative;
    margin-bottom: 25px;
}

.preview-content .code-block-container pre {
    margin-bottom: 0;
}

/* Images within the preview content */
.preview-content img {
    max-width: 100%;
    height: auto;
    margin: 0 0;
    border-radius: 10px;
}

.copy-button {
    position: absolute;
    top: 15px;
    right: 15px;
    background-color: var(--copy-button-bg);
    color: var(--preview-text-color);
    border: none;
    padding: 10px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    opacity: 0.85;
    transition: opacity 0.3s ease, background-color 0.3s ease, transform 0.2s ease;
}

.copy-button:hover {
    opacity: 1;
    background-color: var(--copy-button-hover-bg);
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.copy-button:active {
    transform: translateY(0);
    box-shadow: none;
}


.copy-button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--copy-button-bg-rgb-values), 0.5);
}


/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    .preview-content {
        padding: 30px 25px;
        margin: 0 auto;
        border-radius: 0;
        box-shadow: none;
        font-size: 1rem;
    }

    .preview-content h1 {
        font-size: 2.4rem;
    }

    .preview-content h2 {
        font-size: 2rem;
    }

    .preview-content h3 {
        font-size: 1.6rem;
    }

    .preview-content ul,
    .preview-content ol {
        margin-left: 25px;
    }

    .copy-button {
        padding: 8px 12px;
        font-size: 0.85rem;
        top: 10px;
        right: 10px;
    }
}